#include "XmlFactory.h"

void RXmlFactory::OpenL()
    {
    iDomImplementation.OpenL();
    iDocument.OpenL(iDomImplementation);
    
    _LIT8(KDocumentName, "NfcApiBridgeResponse");
    iDocElement = iDocument.CreateDocumentElementL(KDocumentName);
    }

void RXmlFactory::Close()
    {
    iDocument.Close();
    iDomImplementation.Close();
    }

void RXmlFactory::AddDataL(MXmlSerializable & aObject)
    {
    AddDataL(aObject, iDocElement);
    }

void RXmlFactory::AddDataL(MXmlSerializable & aObject, TXmlEngElement aParent)
    {
    ASSERT(!iDocument.IsNull());
    
    TXmlEngElement elem = iDocument.CreateElementL(aObject.XmlElementName());
    aParent.AppendChildL(elem);
    aObject.SerializeToXmlL(*this, elem);
    }
